<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <head th:replace="common/head"/>
</head>
<body>
<div class="x-body">
    <form class="layui-form" style="padding-bottom: 10px;text-align: left;">
        <div class="layui-form-item">
            编码：
            <div class="layui-inline">
                <input class="layui-input" type="text" name="goodsCode" autocomplete="on" placeholder="商品编码">
            </div>
            商品名称：
            <div class="layui-inline">
                <input class="layui-input" type="text" name="goodsName" autocomplete="on" placeholder="查询字段值">
            </div>
            商品类型：
            <div class="layui-inline">
                <select name="goodsType" lay-search="">
                    <option value="">直接选择或搜索选择</option>
                    <th:block th:each="map: ${goodsType}">
                        <option th:value="${map.key}" th:text="${map.value}"></option>
                    </th:block>
                </select>
            </div>
            销售属性：
            <div class="layui-inline">
                <select name="saleType" lay-search="">
                    <option value="">直接选择或搜索选择</option>
                    <th:block th:each="map: ${saleType}">
                        <option th:value="${map.key}" th:text="${map.value}"></option>
                    </th:block>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            重量单位：
            <div class="layui-inline">
                <select name="weightType" lay-search="">
                    <option value="">直接选择或搜索选择</option>
                    <th:block th:each="map: ${weightType}">
                        <option th:value="${map.key}" th:text="${map.value}"></option>
                    </th:block>
                </select>
            </div>
            包装类型：
            <div class="layui-inline">
                <select name="unitType" lay-search="">
                    <option value="">直接选择或搜索选择</option>
                    <th:block th:each="map: ${unitType}">
                        <option th:value="${map.key}" th:text="${map.value}"></option>
                    </th:block>
                </select>
            </div>
            <button class="layui-btn" lay-submit lay-filter="search"><i class="layui-icon">&#xe615;</i></button>
        </div>
    </form>

    <xblock>
        <button class="layui-btn layui-btn-normal dialog" data-url="/goods/toAdd" data-height="800" data-title="添加">
            <i class="layui-icon">&#xe608;</i>添加
        </button>
    </xblock>

    <input type="hidden" id="editText" value="goods/editText">
    <input type="hidden" id="myEntityId" value="goodsId">
    <input type="hidden" id="checkboxUpdate" value="goods/checkboxUpdate">

    <table class="layui-table"
           lay-data="{url:'/goods/list', page:true,id:'table',limit:15,limits:[10,15,20,50,100]}"
           lay-filter="table">
        <thead>
        <tr>
            <!--<th lay-data="{field:'demo',align:'center', sort: true, edit:'text',templet:'#templetId'}">demo</th>-->
            <!--<th lay-data="{checkbox:true, fixed: true}"></th>-->

            <th lay-data="{field:'goodsCode',align:'center', sort: true}">商品编码</th>
            <th lay-data="{field:'goodsName',align:'center',edit:'text'}">商品名</th>
            <th lay-data="{field:'goodsType',align:'center', sort: true,templet:'#goodsType'}">商品类型</th>
            <th lay-data="{field:'saleType',align:'center', sort: true,templet:'#saleType'}">销售属性</th>
            <th lay-data="{field:'stockCount',align:'center', sort: true}">库存量</th>
            <th lay-data="{field:'unitType',align:'center', sort: true,templet:'#unitType'}">包装类型</th>
            <th lay-data="{field:'weight',align:'center'}">每份的重量</th>
            <th lay-data="{field:'weightType',align:'center', sort: true,templet:'#weightType'}">重量单位</th>
            <th lay-data="{field:'originalPrice',align:'center', sort: true}">进价/成本价</th>
            <th lay-data="{field:'wholesalePrice',align:'center', sort: true}">批发价</th>
            <th lay-data="{field:'retailPrice',align:'center', sort: true}">指导价</th>
            <th lay-data="{field:'status',align:'center',templet:'#status'}">状态</th>
            <th lay-data="{fixed:'right', align:'center',width:120, toolbar: '#row-bar'}">操作</th>
        </tr>
        </thead>
    </table>

    <script type="text/html" id="goodsType" th:inline="javascript">
        {{#  var map = [[${goodsType}]] }}
        {{#  for(var key in map){ }}
        {{#     if(d.goodsType == key){ }}
        {{         unescape(map[key].replace(/\\u/g, '%u')) }}
        {{#     } }}
        {{#  } }}
    </script>

    <script type="text/html" id="saleType" th:inline="javascript">
        {{#  var map = [[${saleType}]] }}
        {{#  for(var key in map){ }}
        {{#     if(d.saleType == key){ }}
        {{         unescape(map[key].replace(/\\u/g, '%u')) }}
        {{#     } }}
        {{#  } }}
    </script>

    <script type="text/html" id="unitType" th:inline="javascript">
        {{#  var map = [[${unitType}]] }}
        {{#  for(var key in map){ }}
        {{#     if(d.unitType == key){ }}
        {{         unescape(map[key].replace(/\\u/g, '%u')) }}
        {{#     } }}
        {{#  } }}
    </script>

    <script type="text/html" id="weightType" th:inline="javascript">
        {{#  var map = [[${weightType}]] }}
        {{#  for(var key in map){ }}
        {{#     if(d.weightType == key){ }}
        {{         unescape(map[key].replace(/\\u/g, '%u')) }}
        {{#     } }}
        {{#  } }}
    </script>

    <script type="text/html" id="status">
        <input type="checkbox" name="status" value="{{d.goodsId}}" lay-skin="switch" lay-text="正常|失效"
               lay-filter="checkbox" {{ d.status== 1 ? 'checked' : '' }}
    </script>

    <script type="text/html" id="row-bar">
        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit" data-url="/goods/toEdit" data-title="编辑商品"
           data-id="goodsId" data-width="800" data-height="800"><i class="layui-icon">&#xe642;</i> 编辑</a>
        <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" data-url='/goods/delete'><i-->
        <!--class="layui-icon">&#xe640;</i> 删除</a>-->
    </script>
</div>
<div th:replace="common/js"></div>
<div th:replace="common/setting"></div>
<script type="text/javascript">
    layui.use('xtable');
</script>
</body>
</html>
